/// @tags: OverallDiv
#include <cstdio>
#include <iostream>
#include <vector>
#define lowbit(x) (x & -x)
#define int long long

using namespace std;

namespace BlueQuantum {

typedef long long ll;

int const N = 3e5 + 5;

struct Event {
  int l, r, a;
} eve[N];

struct Country {
  int p, id;
} c[N], tmpc[N];

int n, m, k;
int ans[N];
ll val[N << 1];
vector<int> sta[N];

inline void modify(int x, ll v) {
  if (!x) return;
  while (x <= 2 * m) val[x] += v, x += lowbit(x);
}

inline ll query(int x) {
  ll res = 0;
  if (!x) return 0;
  while (x) res += val[x], x -= lowbit(x);
  return res;
}

void solve(int ql, int qr, int l, int r) {
  if (l == r) {
    for (int i = ql; i <= qr; ++i) ans[c[i].id] = l;
    return;
  }
  int lqh = ql, rqh = 0;
  int mid = (l + r) >> 1;
  for (int i = l; i <= mid; ++i)
    modify(eve[i].l, eve[i].a), modify(eve[i].r + 1, -eve[i].a);
  for (int i = ql; i <= qr; ++i) {
    ll sum = 0;
    /// @warning sta[c[i].id]
    for (vector<int>::iterator it = sta[c[i].id].begin(), end = sta[c[i].id].end();
         sum < c[i].p && it != end; ++it)
      /// @note 破环成链，一个位置要么在前面加要么在后面加，另一个是0
      sum += query(*it) + query(*it + m);
    if (sum >= c[i].p) c[lqh++] = c[i];
    else {
      tmpc[rqh] = c[i], tmpc[rqh++].p -= sum;
    }
  }
  for (int i = l; i <= mid; ++i)
    modify(eve[i].l, -eve[i].a), modify(eve[i].r + 1, eve[i].a);
  for (int i = lqh; i <= qr; ++i) c[i] = tmpc[i - lqh];
  if (ql != lqh) solve(ql, lqh - 1, l, mid);
  if (lqh <= qr) solve(lqh, qr, mid + 1, r);
}

inline int main() {
  cin >> n >> m;
  for (int i = 1, o; i <= m; ++i) cin >> o, sta[o].push_back(i);
  for (int i = 1; i <= n; ++i) cin >> c[i].p, c[i].id = i;
  cin >> k;
  for (int i = 1; i <= m; ++i) {
    cin >> eve[i].l >> eve[i].r >> eve[i].a;
    if (eve[i].l > eve[i].r) eve[i].r += m;
  }
  solve(1, n, 1, k + 1);
  for (int i = 1; i <= n; ++i) (ans[i] != k + 1 ? cout << ans[i] : cout << "NIE") << '\n';
  return 0;
}

}  // namespace BlueQuantum

signed main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3527 [POI2011] MET-Meteors.in", "r", stdin);
  freopen("P3527 [POI2011] MET-Meteors.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
